<?php
/**
 * Description of AdminIdentity
 *
 * @author Alexey
 */
class AdminIdentity extends CUserIdentity {
    private $_id;

    public function authenticate()
    {
        $admin["adminLogin"] = Yii::app()->params["adminLogin"];
        $admin["adminPassword"] = Yii::app()->params["adminPassword"];
        if ($admin["adminLogin"] != $this->username)
        {
            $this->errorCode = self::ERROR_USERNAME_INVALID;
        }
        else if ($admin["adminPassword"] != $this->password)
        {
            $this->errorCode = self::ERROR_PASSWORD_INVALID;
        }
        else
        {
            $this->_id = "admin";
            $this->setState('login', $admin["adminLogin"]);
            $this->errorCode = self::ERROR_NONE;
        }
        if ($this->errorCode == self::ERROR_NONE)
        {
            return true;
        }
        return false;
    }

    public function getId()
    {
        return $this->_id;
    }
}
?>
